package actions;

import gui.UserPanel;
import information.Job;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.JFrame;

/**
 * An action to view the volunteers for a particular job. 
 * @author Natalie
 *
 */
@SuppressWarnings("serial")
public class ViewVolunteersAction extends AbstractAction {

	final Job myJob;
	
	public ViewVolunteersAction(final Job theJob) {
		super("View Volunteers");
		myJob = theJob;
	}
	
	/**
	 * Creates a new frame and displays the list of volunteers for the specific job on it. 
	 */
	@Override
	public void actionPerformed(ActionEvent arg0) {
		JFrame frame = new JFrame();
		frame.setLayout(new BorderLayout());
		UserPanel panel = new UserPanel(null);
		panel.displayVolunteerList(myJob.getVolunteers(), "Volunteers For Job");
		frame.add(panel, BorderLayout.CENTER);
		frame.pack();
		frame.setVisible(true);

	}

}
